home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 6173 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Newbie Q: references
  5. Date: 10 Feb 1996 16:17:34 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4figeu$24l@news1.usa.pipeline.com>
  8. References: <4fegaq$gvc@dns.plano.net>
  9. NNTP-Posting-Host: pipe12.h1.usa.pipeline.com
  10. X-PipeUser: grantp
  11. X-PipeHub: usa.pipeline.com
  12. X-PipeGCOS: (Pete)
  13. X-Newsreader: Pipeline USA v3.3.0
  14.  
  15. On Feb 09, 1996 03:50:50 in article <Re: Newbie Q: references>,
  16. 'jdunn@plano.net' wrote: 
  17.  
  18.  
  19. >I'll take another pass at this with hard returns: 
  20. >As I understand what happens under the compiler covers, when we 
  21. >pass a reference into a method (function), what actually happens is 
  22. >that the compiler creates another entry in it's symbol table to alias  
  23. >the same address location. This new alias has a different scope and 
  24. >is scoped only in the function it is passed to.  
  25. Did you read this somewhere?  The scoping part is right, but how 
  26. the reference is passed to a function is implementation-dependent. 
  27.  
  28. >Does that mean that the compiler actually does not put any thing at  
  29. >all on the stack for the reference, but just allows you to use the 
  30. >reference inside the function's scope? 
  31. No.  Most implementations pass the reference the same way as a 
  32. pointer.  In other words, the only difference between a pointer 
  33. and a reference to an object is the semantics in the language. 
  34.  
  35. >Is this the real reason for references ?  That they take no overhead 
  36. in the function calls and returns ? 
  37. No, overhead is the same as for pointers. 
  38.  
  39. As for the reason, here's a sentence from Stroustrup's book: 
  40. "References were introduced primarily to support operator 
  41. overloading." 
  42. -- 
  43. Pete Grant 
  44. Kalevi, Inc. 
  45. Object Oriented Software Development
  46.